Repository navigation
fix: recover stale luks device mapper - #1364
lukasmetzner wants to merge 7 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1364 +/- ##
==========================================
- Coverage 79.49% 77.72% -1.77%
==========================================
Files 19 19
Lines 1453 1486 +33
==========================================
Hits 1155 1155
- Misses 298 331 +33
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Debugging information provided by customer indicates there is an issue with luks device mappers not being closed properly. I could not yet reproduce this correctly, but this would address the issue. |
|
As an addition, I properly introduced context management into the cryptsetup. Required a little refactor, but this is mostly just dragging along the context. |
7b0980e to
23ee4c1
Compare
4ab707d to
09cd36f
Compare
|
@lukasmetzner I think we got hit by somthing related to this pr AIA dm-crypt mapper left over from an earlier attach cycle stayed active while pointing at a dead I ran this PR's |
8fe7cca to
9e7aa75
Compare
9e7aa75 to
cb75ce8
Compare
| func (cs *CryptSetup) IsActive(ctx context.Context, luksDeviceName string) (bool, error) { | ||
| output, code, err := command(ctx, cryptsetupExecuable, "status", luksDeviceName) | ||
| func (cs *CryptSetup) Status(ctx context.Context, luksDeviceName string) (LUKSDeviceStatus, error) { | ||
| output, code, err := cryptsetup(ctx, "status", luksDeviceName) |
There was a problem hiding this comment.
Possibly replace with a library and don't parse output.
If a Volume is detached without being unpublished (e.g. node crash, forced detach), its dm-crypt mapper
scsi-0HC_Volume_<id>stays active while its backing device is gone.cryptsetup statusthen reports:When the Volume is attached again,
CryptSetup.Openonly checked the exit code ofcryptsetup statusand reused the stale mapper. mount-utils could not read a filesystem from it, treated it as unformatted and ranmkfs.ext4 -Fagainst the dead device, failing and retrying on every publish.With this change,
Openreuses an active mapper only if its backing device is the device verified in #1457 (same device number). Otherwise, the mapper is closed and opened again on the correct device. If the stale mapper is still mounted, closing it fails and the publish errors out instead of formatting.